package com.ja.openchat.ui.me;

import android.os.Bundle;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.ja.openchat.BR;
import com.ja.openchat.R;
import com.ja.openchat.ui.base.JaBaseActivity;
import com.ja.openchat.ui.message.adapter.SimpleFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class LatestCallActivity extends JaBaseActivity {

    @BindView(R.id.tablayout)
    TabLayout tablayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    @BindView(R.id.tv_bar_title)
    AppCompatTextView tvBarTitle;

    @Override
    protected boolean isHaveButterKnife() {
        return true;
    }

    @Override
    public void initData() {
        super.initData();
        tvBarTitle.setText(getString(R.string.lasted_call_text));
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(LatestCallFragment.newInstance(0));
        fragments.add(LatestCallFragment.newInstance(1));
        fragments.add(LatestCallFragment.newInstance(2));
        SimpleFragmentPagerAdapter fragmentAdater = new SimpleFragmentPagerAdapter(getSupportFragmentManager()
                , fragments
                , new String[]{getString(R.string.all_calls), getString(R.string.call_out), getString(R.string.call_in)});
        viewPager.setAdapter(fragmentAdater);
        viewPager.setOffscreenPageLimit(fragments.size());
        tablayout.setupWithViewPager(viewPager);
    }


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_latest_call;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

}
